import { creatElement, render, Component } from './toy-react';

// 默认继承 当没有设置方法时 使用默认值
class MyComponent extends Component{
    constructor() {
        super(); // 继承父类的模式
        this.state = {
            a: 1,
            b: 2
        }
    }
    render() {
        return <div>
            <h1>my component</h1>
            <button onclick={() => {this.setState({a: this.state.a ++ })}}>add</button>
            <span>{this.state.a.toString()}</span>
        </div>
    }
}



let element = <MyComponent id='app' class='app'>
    <div>aaa</div>
    <div></div>
    <div></div>
    <div></div>
</MyComponent>

// document.body.appendChild(element);
render(element, document.body)